package demo1;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.stereotype.Component;

/***
 * 通过三种不同方式调用personlei方法
 */

public class Demo {
    public static void main(String[] args) throws Exception {
        Person p=new Person();
        p.sayHello();

        Class cls=Class.forName("demo1.Person");
        Person p2=(Person)cls.newInstance();
        p2.sayHello();

        //通过spring容器获取对象
        AnnotationConfigApplicationContext context
                =new AnnotationConfigApplicationContext("demo1");
        Person p3=context.getBean(Person.class);
        p3.sayHello();

    }
}
